<!DOCTYPE html>
<HTML>
<HEAD>
	<TITLE> ZTREE DEMO - checkbox</TITLE>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" href="../../../css/demo.css" type="text/css">
	<link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../../../js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
	<!--
	<script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>
	-->
	    <SCRIPT type="text/javascript">
        <!--
        var setting = {    
            check:{
            //chkboxType: { "Y": "ps", "N": "ps" },
            chkStyle: "checkbox",//复选框类型
            enable: true //每个节点上是否显示 CheckBox
           },
            /*data: {
                simpleData: {
                    enable: true
                }
            }*/
            data:    {
                simpleData:{
                    enable:true
                }
            },
            callback:{
                 beforeCheck:true,
                onCheck:onCheck
            }
            
        };
                    
        var zNodes =[
            { id:"随意勾选 1", pId:"随意勾选 1", name:"随意勾选 1", open:false},
            { id:"随意勾选 1-1", pId:"随意勾选 1", name:"随意勾选 1-1", open:true},
            { id:"随意勾选 1-1-1", pId:"随意勾选 1-1", name:"随意勾选 1-1-1"},
            { id:"随意勾选 1-1-2", pId:"随意勾选 1-1", name:"随意勾选 1-1-2"},
            { id:"随意勾选 2", pId:"随意勾选 2", name:"随意勾选 2", open:false},
            { id:"随意勾选 2-1", pId:"随意勾选 2", name:"随意勾选 2-1", open:false},
             { id:"随意勾选 2-1-1", pId:"随意勾选 2-1", name:"随意勾选 2-1-1"},
            	
        ];
        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
            
            function onCheck(e,treeId,treeNode){
            var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),
            nodes=treeObj.getCheckedNodes(true),
            v="";
            for(var i=0;i<nodes.length;i++){
            v+=nodes[i].name + ",";
            console.log("节点id:"+nodes[i].id+"节点名称"+v); //获取选中节点的值
            }
            
            
            }
            function aaa(){
            var treeObj=$.fn.zTree.getZTreeObj("treeDemo");
            nodes=treeObj.getCheckedNodes(true);
            console.log(nodes);
             for(var i=0;i<nodes.length;i++){
            		if(nodes[i].check_Child_State < 1){
            			console.log(nodes[i].name);
            		}
            
            }
            
            }
            
           
    </SCRIPT>
</HEAD>

<BODY>


<div class="zTreeDemoBackground left">
        <ul id="treeDemo" class="ztree"></ul>
    </div>
    <a onclick="aaa()">aaa</a>
</BODY>
</HTML>